﻿package mortal.game.view.forging.data
{
    import com.gengine.utils.*;
    import mortal.common.global.*;
    import mortal.game.resource.*;
    import mortal.game.resource.tableConfig.*;

    public class ForgingUtil extends Object
    {
        private var _gemPropNameMap:HashMap;
        private static var _instance:ForgingUtil;

        public function ForgingUtil()
        {
            if (_instance != null)
            {
                throw new Error("ForgingUtil 单例");
            }
            this.init();
            return;
        }// end function

        private function init() : void
        {
            this._gemPropNameMap = new HashMap();
            this._gemPropNameMap.push(1, GameDefConfig.instance.getAttributeName("attack"));
            this._gemPropNameMap.push(2, GameDefConfig.instance.getAttributeName("life"));
            this._gemPropNameMap.push(4, GameDefConfig.instance.getAttributeName("physDefense"));
            this._gemPropNameMap.push(5, GameDefConfig.instance.getAttributeName("magicDefense"));
            this._gemPropNameMap.push(6, GameDefConfig.instance.getAttributeName("penetration"));
            this._gemPropNameMap.push(7, GameDefConfig.instance.getAttributeName("jouk"));
            this._gemPropNameMap.push(8, GameDefConfig.instance.getAttributeName("hit"));
            this._gemPropNameMap.push(9, GameDefConfig.instance.getAttributeName("crit"));
            this._gemPropNameMap.push(10, GameDefConfig.instance.getAttributeName("toughness"));
            this._gemPropNameMap.push(11, GameDefConfig.instance.getAttributeName("block"));
            this._gemPropNameMap.push(12, GameDefConfig.instance.getAttributeName("expertise"));
            return;
        }// end function

        public function getGemPropName(param1:int) : String
        {
            return this._gemPropNameMap.getValue(param1) as String;
        }// end function

        public function getAttrNameByType(param1:int) : String
        {
            var _loc_2:* = GameDefConfig.instance.getItem("FightRoleAttribute", param1).text1;
            return _loc_2;
        }// end function

        public function getAddtionValue(param1:int, param2:int) : int
        {
            var _loc_3:* = GameDefConfig.instance.getItem("FightRoleAttribute", param1).text;
            _loc_3 = _loc_3 == "physDefense" ? ("physicalDefense") : (_loc_3);
            _loc_3 = _loc_3 == "magicDefense" ? ("magicalDefense") : (_loc_3);
            _loc_3 = _loc_3 == "life" ? ("maxLife") : (_loc_3);
            _loc_3 = _loc_3 == "mana" ? ("maxMana") : (_loc_3);
            var _loc_4:* = EquipRefreshConfig.instance.getAttrValue(param2, _loc_3);
            return _loc_4;
        }// end function

        public function getLevelRange(param1:int) : int
        {
            if (param1 <= 20)
            {
                return 20;
            }
            if (param1 <= 30)
            {
                return 30;
            }
            if (param1 <= 40)
            {
                return 40;
            }
            if (param1 <= 50)
            {
                return 50;
            }
            if (param1 <= 60)
            {
                return 60;
            }
            if (param1 <= 70)
            {
                return 70;
            }
            if (param1 <= 80)
            {
                return 80;
            }
            if (param1 <= 90)
            {
                return 90;
            }
            if (param1 <= 100)
            {
                return 90;
            }
            return 0;
        }// end function

        public function getPropColor(param1:int, param2:int) : uint
        {
            var _loc_3:uint = 0;
            var _loc_4:* = param1 / param2 as Number;
            if (_loc_4 >= 0 && _loc_4 < 0.6)
            {
                _loc_3 = GlobalStyle.colorLvUint;
            }
            if (_loc_4 >= 0.6 && _loc_4 < 0.8)
            {
                _loc_3 = GlobalStyle.colorLanUint;
            }
            if (_loc_4 >= 0.8 && _loc_4 < 1)
            {
                _loc_3 = GlobalStyle.colorZiUint;
            }
            if (_loc_4 >= 1)
            {
                _loc_3 = GlobalStyle.colorChenUint;
            }
            return _loc_3;
        }// end function

        public static function get instance() : ForgingUtil
        {
            if (_instance == null)
            {
                _instance = new ForgingUtil;
            }
            return _instance;
        }// end function

    }
}
